const { SmsProxy } = require('../proxy');

module.exports = {
	//发送短信
	send: function(req, res, next){
		var telephoto = req.body.telephoto;  //手机号
		var code_num = req.body.code_num;  //短信验证码
		console.log(telephoto, code_num)
		//查看该手机号是否被注册
		SmsProxy.ckeckTele(telephoto)
		.then((data)=>{
			if(data){  //已经被注册了
				res.send({msg:'Has'}).end();
			}else{
				//发送短信
				SmsProxy.send(telephoto, code_num)
				.then((response)=>{
					//console.log('结果',response.data)
					if(response.data.msg == 'OK'){
						res.send({msg:'OK'}).end();
					}
				});
			}
		});
		
	}
}
